var _page = $('.page');


/// 上传音频
bottlecms.layuiuploadfile({
    elem: ".js_up_recorder",
    accept: "audio",
    filedir: "voice",
    success: function (voice) {
        bottlecms.post("/m/ajax/center/single/modify", {voice: voice}, function (data) {
            if (data.success == true) {
                if (data.obj) {
                    $(".voicebox .bcui_voice audio").attr('src', voice);
                    $(".voicebox .bcui_voice").show();
                    $(".voicebox .placeholder").hide();
                }
                location.reload();
            } else {
                bottlecms.toast(data.msg);
            }
        });
    }
});


/// 上传视频
bottlecms.layuiuploadfile({
    elem: ".js_up_video",
    accept: "video",
    filedir: "video",
    success: function (video) {
        bottlecms.post("/m/ajax/center/single/modify", {video: video}, function (data) {
            if (data.success == true) {
                if (data.obj) {
                    $(".videobox").html('<video style="background: #000" width="300" height="200" controls="controls" preload="" src="' + video + '"></video>');
                }
                location.reload();
            } else {
                bottlecms.toast(data.msg);
            }
        });
    }
});


// 删除录音
$(_page).on('click', '.js_del_recorder', function () {
    var _this = this;
    bottlecms.confirm("确定要删除吗？", function () {
        bottlecms.delete("/m/ajax/center/single/removeShow", {voice: "1"}, function (data) {
            if (data.success == true) {
                bottlecms.toast(data.msg);
                location.reload();
            } else {
                bottlecms.toast(data.msg);
            }
        });
    })
});
// 删除视频
$(_page).on('click', '.js_del_video', function () {
    var _this = this;
    bottlecms.confirm("确定要删除吗？", function () {
        bottlecms.post("/m/ajax/center/single/removeShow", {video: "1"}, function (data) {
            if (data.success == true) {
                bottlecms.toast(data.msg);
                location.reload();
            } else {
                bottlecms.toast(data.msg);
            }
        });
    })
});